package com.epalmpay.controller.apiweixin;

import com.epalmpay.commom.BaseController;
import com.epalmpay.dto.order.MallOrderQueryDTO;
import com.epalmpay.entity.*;
import com.epalmpay.exception.ApplicationException;
import com.epalmpay.mapper.MallEntityGoodMapper;
import com.epalmpay.service.mall.IMallGoodService;
import com.epalmpay.service.member.IMemberService;
import com.epalmpay.service.order.IOrderGoodService;
import com.epalmpay.service.order.IOrderService;
import com.epalmpay.service.shop.IShopService;
import com.epalmpay.service.weixin.IWxApiWalletService;
import com.epalmpay.service.weixin.IWxBaseService;
import com.epalmpay.service.weixin.impl.WxService;
import com.epalmpay.status.Rescode;
import com.epalmpay.service.weixin.IWxApiMallService;
import com.epalmpay.util.Base64Utils;
import com.epalmpay.util.FileUpload;
import com.epalmpay.util.PageData;
import com.epalmpay.util.Tools;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;

/**
 * Created by lifayi on 2017/10/12.
 */
@RestController
@RequestMapping("/api/weixin/mall")
public class WxApiMallController  extends BaseController {

    @Resource
    private IWxApiMallService wxApiMallService;
    @Resource
    private FileUpload fileUpload;

    @Autowired
    protected WxService wxService;
    @Autowired
    protected IWxBaseService wxBaseService;
    @Resource
    private IWxApiWalletService wxApiWalletServiceService;
    @Resource
    private IMemberService memberService;

    @Resource
    private IShopService shopService;
    @Resource
    private IMallGoodService mallGoodService;
    @Resource
    private IOrderGoodService orderGoodService;//实体商品订单
    @Resource
    private IOrderService orderService;//服务商品订单
    /*
    * 广告
    */
    @RequestMapping("/advertise")
    public Response advertise(@RequestParam Long groupId) {
        return wxApiMallService.advertise(groupId);
    }

    /*
    * 导航栏目
    */
    @RequestMapping("/category")
    public Response category(@RequestParam Long groupId) {
        return wxApiMallService.category(groupId);
    }

    /*
    * 首页商品
    */
    @RequestMapping("/recommendGood")
    public Response goodList(@RequestParam Long groupId, @RequestParam Integer pageNo, @RequestParam Integer pageSize) {
        return wxApiMallService.recommendGood(groupId, pageNo, pageSize);
    }

    /*
    * 查询实物商品列表
    */
    @RequestMapping(value = "/queryGoodList", method = RequestMethod.POST)
    @ResponseBody
    public Response queryGoodList(@RequestParam(required = true) Long groupId,
                                  @RequestParam(required = false) Long categoryFirstId,
                                  @RequestParam(required = false) Long categorySecondId,
                                  @RequestParam(required = false) String goodName,
                                  //@RequestParam(required = false) String userLongitude,
                                  //@RequestParam(required = false) String userLatitude,
                                  //@RequestParam(required = false) Integer distance,
                                  @RequestParam(required = true) Integer sortMethod,
                                  @RequestParam(required = true) Integer pageNo,
                                  @RequestParam(required = true) Integer pageSize) {
        logBefore(logger, "查询商品列表");
        Map<String, Object> map = null;

        try {
            map = wxApiMallService.queryGoodList(groupId, categoryFirstId,categorySecondId,goodName,sortMethod,
                    pageNo, pageSize);
            if(map == null || map.size()==0){
                throw new ApplicationException(Rescode.FAIL,"未查询到记录");
            }
            return Response.getSuccess(map);
        } catch (ApplicationException ae) {
            logger.error(ae);
            return Response.getError(ae.errMsg);
        }
        catch (Exception e) {
            logger.error(e);
            return Response.getError("服务器异常");
        }
    }

    /*
    * 商品详情
    */
    @RequestMapping("/goodDetail")
    public Response goodDetail(@RequestParam Long goodId) {
        return wxApiMallService.goodDetail(goodId);
    }

    /*
    * 单商品订单提交
    */
    @RequestMapping("/submitOrder")
    public Response submitOrder(@RequestParam Long memberId , @RequestParam Long goodId, @RequestParam Integer goodsNum,
                                @RequestParam Long address_id, @RequestParam Integer intergral, @RequestParam String couponSns,
                                Long specId, Long sharememberid) {
        try {
            return wxApiMallService.saveSubmitOrder(memberId, goodId, goodsNum, address_id, intergral, couponSns, specId, sharememberid);
        } catch (ApplicationException e) {
            e.printStackTrace();
            return Response.getError("服务器处理错误");
        }
    }

    /*
    * 购物车结算
    * 这里的goodIds表示购物车ID
    */
    @RequestMapping("/submitCart")
    public Response submitCart(@RequestParam Long memberId, @RequestParam String goodIds) {
        if(Tools.isEmpty(goodIds)) {
            return Response.getError("请求非法");
        } else {
            String[] goodIdsStr = goodIds.split(",");
            ArrayList<Long> goodIds1 = new ArrayList<>();
            for(String goodIdStr : goodIdsStr) {
                goodIds1.add(Long.parseLong(goodIdStr));
            }
            return wxApiMallService.saveSubmitCart(memberId, goodIds1);
        }
    }

    /*
    * 购物车订单提交
    * 这里的goodIds表示购物车ID
    */
    @RequestMapping("/submitCartOrder")
    public Response submitCartOrder(@RequestParam Long memberId, @RequestParam String goodIds, @RequestParam Long address_id,
                                    @RequestParam Integer intergral, String couponSns) {
        if(Tools.isEmpty(goodIds)) {
            return Response.getError("请求非法");
        } else {
            String[] goodIdsStr = goodIds.split(",");
            ArrayList<Long> goodIds1 = new ArrayList<>();
            for(String goodIdStr : goodIdsStr) {
                goodIds1.add(Long.parseLong(goodIdStr));
            }
            try {
                return wxApiMallService.saveSubmitCartOrder(memberId, goodIds1, address_id, intergral, couponSns);
            } catch (ApplicationException e) {
                return Response.getError(e.errMsg);
            }
        }
    }

    /*
    * 订单支付（钱包）
    * 这里的orderId表示订单号 而不是订单ID
    */
    @RequestMapping("/walletPay")
    public Response walletPay(@RequestParam Long memberId, @RequestParam String orderId, @RequestParam String payPwd) throws ExecutionException, InterruptedException {
        if(Tools.isEmpty(payPwd)) {
            return Response.getError("请求错误或者支付密码为空");
        }
        try {
            return wxApiMallService.saveWalletPay(memberId, orderId, payPwd, ROOT_HOME_URL);
        } catch (ApplicationException e) {
            e.printStackTrace();
            return Response.getError(e.getErrMsg());
        }
    }

    /*
    * 订单支付（微信）
    * 这里的orderId表示订单号 而不是订单ID
    */
    @RequestMapping("/wexinPay")
    public Response weixinPay(@RequestParam Long memberId, @RequestParam String orderId, HttpServletRequest request) {
        String merchantIp = Tools.getIpAddr(request);
        try {
        	String notifyUrl = HOME_URL + "/payplat/callback/rechargeTkNotify";
            return wxApiMallService.saveWeixinPay(memberId, orderId,merchantIp,notifyUrl);
        } catch (ApplicationException e) {
            e.printStackTrace();
            return Response.getError(e.getErrMsg());
        }
    }

    /*
    * 订单支付（快捷卡）
    */
    @RequestMapping("/existCardsubmit")
    public Response existCardsubmit(@RequestParam Long memberId, @RequestParam String orderId, @RequestParam Long cardId, HttpServletRequest request) {
        String merchantIp = Tools.getIpAddr(request);
        try {
            return wxApiMallService.saveCardPay(memberId, orderId, cardId, merchantIp);
        } catch (ApplicationException e) {
            e.printStackTrace();
            return Response.getError(e.getErrMsg());
        }
    }

    /*
    * 订单列表
    */
    @RequestMapping("/orderList")
    public Response orderList(@RequestParam Long memberId, @RequestParam Integer status,
                              @RequestParam Integer pageNo, @RequestParam Integer pageSize) {
        return wxApiMallService.orderList(memberId, status, pageNo, pageSize);
    }

    /*
    * 获取会员优惠券积分
    */
    @RequestMapping("/availableBenefit")
    public Response availableBenefit(@RequestParam Long memberId, @RequestParam Long goodsId, @RequestParam Integer tradeAmt) throws ParseException {
        return wxApiMallService.availableBenefit(memberId, goodsId, tradeAmt);
    }

    /*
     * 获取服务商品会员优惠券积分
     */
     @RequestMapping("/availableBenefitByServiceMall")
     public Response availableBenefitByServiceMall(@RequestParam Long memberId, @RequestParam Long goodsId, @RequestParam Integer tradeAmt) throws ParseException {
         return wxApiMallService.availableBenefitByServiceMall(memberId, goodsId, tradeAmt);
     }
    
    /*
    * 购物车获取会员优惠券积分
    * 这里的goodsIds表示购物车Id
    */
    @RequestMapping("/availableBenefitCart")
    public Response availableBenefitCart(@RequestParam Long memberId, @RequestParam String goodsIds) throws ParseException {
        if(Tools.isEmpty(goodsIds)) {
            return Response.getError("请求非法");
        } else {
            String[] goodIdsStr = goodsIds.split(",");
            ArrayList<Long> goodIds = new ArrayList<>();
            for(String goodIdStr : goodIdsStr) {
                goodIds.add(Long.parseLong(goodIdStr));
            }
            return wxApiMallService.availableBenefitCart(memberId, goodIds);
        }
    }

    /*
    * 运费计算(如果商品有规格则需要传specId)
    */
    @RequestMapping("/getFreight")
    public Response getFreight(@RequestParam Long memberId, @RequestParam Long addressId, @RequestParam Long goodsId,
                               @RequestParam Integer goodsNum, Long specId) {
        return wxApiMallService.getFreight(memberId, addressId, goodsId, goodsNum, specId);
    }

    /*
    * 购物车运费计算
    * 这里的goodsIds表示购物车ID
    */
    @RequestMapping("/getFreightCart")
    public Response getFreightCart(@RequestParam Long memberId, @RequestParam Long addressId, @RequestParam String goodsIds) {
        if(Tools.isEmpty(goodsIds)) {
            return Response.getError("请求非法");
        } else {
            String[] goodIdsStr = goodsIds.split(",");
            ArrayList<Long> goodIds = new ArrayList<>();
            for(String goodIdStr : goodIdsStr) {
                goodIds.add(Long.parseLong(goodIdStr));
            }
            return wxApiMallService.getFreightCart(memberId, addressId, goodIds);
        }
    }

    /*
    * 申请退款
    */
    @RequestMapping("/orderRefund")
    public Response orderRefund(@RequestParam Long memberId, @RequestParam Long orderId, @RequestParam Integer isReceivedGood,
                                String refundReason, HttpServletRequest request) {
        String path = "/ebos/mall/refund/";

        String picUrls = "";

        String img1Str = request.getParameter("img1");
        String img2Str = request.getParameter("img2");
        String img3Str = request.getParameter("img3");

//        MultipartFile img1 = null, img2 = null , img3 = null;
//        CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(request.getSession().getServletContext());
//        if(multipartResolver.isMultipart(request)) {
//            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
//            img1 = multipartRequest.getFileMap().get("img1");
//            img2 = multipartRequest.getFileMap().get("img2");
//            img3 = multipartRequest.getFileMap().get("img3");
//        }

        if(!Tools.isEmpty(img1Str)) {
            String extName = img1Str.split(";")[0].substring(11);

            String result = fileUpload.upload(img1Str.replaceFirst("data.*,", ""),"test." + extName , path);
            if(!result.equals("failed")) {
                picUrls += result + ",";
            }
        }
        if(!Tools.isEmpty(img2Str)) {
            String extName = img1Str.split(";")[0].substring(11);
            String result = fileUpload.upload(img2Str.replaceFirst("data.*,", ""),"test." + extName, path);
            if(!result.equals("failed")) {
                picUrls += result + ",";
            }
        }
        if(!Tools.isEmpty(img3Str)) {
            String extName = img1Str.split(";")[0].substring(11);
            String result = fileUpload.upload(img3Str.replaceFirst("data.*,", ""),"test." + extName, path);
            if(!result.equals("failed")) {
                picUrls += result + ",";
            }
        }
        return wxApiMallService.orderRefund(memberId, orderId, isReceivedGood, refundReason, picUrls);
    }

    /*
    * 会员收货地址详情
    */
    @RequestMapping("/addressDetail")
    public Response addressDetail(@RequestParam Long memberId, @RequestParam Long addressId) {
        return wxApiMallService.addressDetail(memberId, addressId);
    }

    /*
    * 确认收货
    */
    @RequestMapping("/goodReceived")
    public Response goodReceived(@RequestParam Long memberId, @RequestParam Long orderId) {
        return wxApiMallService.goodReceived(memberId, orderId);
    }

    /**
     * 活动门店
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getCanUsedShopListByCouponId", method = RequestMethod.POST)
    @ResponseBody
    public com.epalmpay.util.Response activityShop(@RequestParam(required = true) Long couponId,
                                                   @RequestParam(required = false) String user_longitude,
                                                   @RequestParam(required = false) String user_latitude) throws Exception {
        logBefore(logger, "活动门店");
        Map<String, Object> map = null;

        try {
            map = wxApiMallService.getCanUsedShopListByCouponId(couponId,user_longitude,user_latitude);
            if(map == null || map.size()==0){
                throw new ApplicationException(Rescode.FAIL,"未查询到记录");
            }
            return com.epalmpay.util.Response.getSuccess(map);
        } catch (ApplicationException ae) {
            logger.error(ae);
            return com.epalmpay.util.Response.getError(ae.errMsg);
        }
        catch (Exception e) {
            logger.error(e);
            return com.epalmpay.util.Response.getError("服务器异常");
        }
    }

    /**
     * 查询线上优惠券可用商品列表
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/queryGoodListByOnlineCouponId", method = RequestMethod.POST)
    @ResponseBody
    public com.epalmpay.util.Response queryGoodListByOnlineCouponId(@RequestParam(required = true) Long couponId) throws Exception {
        logBefore(logger, "查询线上优惠券可用商品列表");
        Map<String, Object> map = null;

        try {
            map = wxApiMallService.queryGoodListByOnlineCouponId(couponId);
            if(map == null || map.size()==0){
                throw new ApplicationException(Rescode.FAIL,"未查询到记录");
            }
            return com.epalmpay.util.Response.getSuccess(map);
        } catch (ApplicationException ae) {
            logger.error(ae);
            return com.epalmpay.util.Response.getError(ae.errMsg);
        }
        catch (Exception e) {
            logger.error(e);
            return com.epalmpay.util.Response.getError("服务器异常");
        }
    }


    /**
     * 分享商品获取优惠券
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/shareGetCoupon", method = RequestMethod.POST)
    @ResponseBody
    public com.epalmpay.util.Response shareGetCoupon(@RequestParam(required = true) String memberId,@RequestParam(required = true) String goodId,@RequestParam(required = true) int type) throws Exception {
        logBefore(logger, "分享获取优惠券");
        HashMap<String, String> mapCheck = new HashMap<String, String>();
        mapCheck.put("会员id", memberId);
        mapCheck.put("商品id", goodId);
        String nullParam= com.epalmpay.util.Response.checkNull(mapCheck);
        if (null != nullParam) {
            return com.epalmpay.util.Response.getError(nullParam+"不能为空");
        }
        Map<String, Object> map = null;
        try {
            int result  = wxApiMallService.insertCouponUser(memberId,goodId,type);
          /*  if(result == -1)
                throw new ApplicationException(Rescode.FAIL,"优惠券已经结束!");
            if(result == -2)
                throw new ApplicationException(Rescode.FAIL,"优惠券已经领取完成!");
            if(result == -3)
                throw new ApplicationException(Rescode.FAIL,"优惠券已经过期!");
            if(result == -4)
                throw new ApplicationException(Rescode.FAIL,"过了有效结束时间!");
            if(result == -5)
                throw new ApplicationException(Rescode.FAIL,"超过最大领取张数!");*/

            return com.epalmpay.util.Response.getSuccess(null);
        } catch (ApplicationException ae) {
            logger.error(ae);
            return com.epalmpay.util.Response.getError(ae.errMsg);
        }
        catch (Exception e) {
            logger.error(e);
            return com.epalmpay.util.Response.getError("服务器异常");
        }
    }

    /**
     * 分享活动获取优惠券
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/shareActivityGetCoupon", method = RequestMethod.POST)
    @ResponseBody
    public com.epalmpay.util.Response shareActivityGetCoupon(@RequestParam(required = true) String memberId,@RequestParam(required = true) String activityId) throws Exception {
        logBefore(logger, "分享获取优惠券");
        HashMap<String, String> mapCheck = new HashMap<String, String>();
        mapCheck.put("会员id", memberId);
        mapCheck.put("活动id", activityId);
        String nullParam= com.epalmpay.util.Response.checkNull(mapCheck);
        if (null != nullParam) {
            return com.epalmpay.util.Response.getError(nullParam+"不能为空");
        }
        Map<String, Object> map = null;
        try {
            map= wxApiMallService.addCouponUser(memberId,activityId);
            if(map == null || map.size()==0){
                throw new ApplicationException(Rescode.FAIL,"未查询到记录");
            }
            return com.epalmpay.util.Response.getSuccess(map);
        } catch (ApplicationException ae) {
            logger.error(ae);
            return com.epalmpay.util.Response.getError(ae.errMsg);
        }
        catch (Exception e) {
            logger.error(e);
            return com.epalmpay.util.Response.getError("服务器异常");
        }
    }

    /**
     * 重定向至微信页
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/goodDetailIndex",method = {RequestMethod.GET,RequestMethod.POST} )
    public String goodDetailIndex(HttpServletRequest request, HttpServletResponse response) throws Exception{
        logBefore(logger, "微信第二步授权开始");
        PageData pd = new PageData();
        pd = this.getPageData();
        String groupId=pd.getString("groupId");
        String code=pd.getString("code");
        String goodId = pd.getString("gid");//商品编号
        String memberid = pd.getString("memberid");//分享者编号

        wxService.setWxMpConfigStorage(wxBaseService.getTokenByGroupId(Long.parseLong(groupId)));
        WxMpOAuth2AccessToken wxMpOAuth2AccessToken = this.wxService.oauth2getAccessToken(code);
        String openId=wxMpOAuth2AccessToken.getOpenId();
        //根据openid获取会员id
        Member member = memberService.findByOpenId(openId, Long.parseLong(groupId));
        Long uid = null;
        if(member != null) {//如果用户存在，则获取会员编号
            uid = member.getId();
        } else {//如果用户不存在则添加用户
            uid = memberService.addMemberInfo(groupId, openId, memberid);
        }

        //根据openId查询会员ID
        String url = String.format("%s/" + groupId + "/shop_goods_detail.html", ROOT_HOME_URL);
        url = url +"?uid="+uid+"&gid="+goodId+"&memberid="+memberid+"&share=1&groupid="+groupId;

        logBefore(logger, "微信第二步授权结束");
        response.sendRedirect(url);
        return null;
    }


    /**
     * 根据门店名，查询门店信息
     * @param groupId
     * @param shopName
     * @return
     */
    @RequestMapping(value = "/getShopByName", method = RequestMethod.POST)
    public Response getShopByName(@RequestParam Long groupId,@RequestParam String shopName)  {
        logBefore(logger,"根据渠道ID和门店名称，获取门店信息");
        if(groupId == null || Tools.isEmpty(shopName)){
            return Response.getError("缺失请求参数");
        }else{
            try {
                return Response.getSuccess(shopService.getShopByName(groupId,shopName));
            } catch (Exception e) {
                e.printStackTrace();
                logBefore(logger,e.getMessage());
                return Response.getError(e.getMessage());
            }
        }
    }

    /**
     * 根据商品名称查询商品信息
     * @param groupId 渠道ID
     * @param goodsName 商品名称
     * @param type  商品类型 0服务商品，1实体商品
     * @return
     */
    @RequestMapping(value = "/getGoodsByName", method = RequestMethod.POST)
    public Response getGoodsByName(@RequestParam Long groupId,@RequestParam String goodsName,@RequestParam String type){
        logBefore(logger,"根据商品名称查询商品信息");
        if(groupId == null || Tools.isEmpty(goodsName) || Tools.isEmpty(type)){
            return Response.getError("缺失请求参数");
        }else{
            if(type.equals("0")){
                //服务商品
                try {
                    logBefore(logger,"根据商品名称搜索服务商品信息");
                    MallGood mallGood = new MallGood();
                    mallGood.setGroupId(groupId);
                    mallGood.setGoodName(goodsName);

                    return Response.getSuccess(mallGoodService.getServiceGoodByName(mallGood));
                } catch (Exception e) {
                    e.printStackTrace();
                    logBefore(logger,e.getMessage());
                    return Response.getError(e.getMessage());
                }
            }else if(type.equals("1")){
                //实体商品
                try {
                    logBefore(logger,"根据商品名称搜索实体商品信息");
                    MallEntityGood mallEntityGood = new MallEntityGood();
                    mallEntityGood.setGroupId(groupId);
                    mallEntityGood.setName(goodsName);

                    return Response.getSuccess(mallGoodService.getEntityGoodByName(mallEntityGood));
                } catch (Exception e) {
                    e.printStackTrace();
                    logBefore(logger,e.getMessage());
                    return Response.getError(e.getMessage());
                }

            }else{
                return Response.getError("商品类型参数异常");
            }
        }
    }

    /**
     * 根据渠道ID，会员ID，商品名称，订单状态
     * @param groupId
     * @param goodsName
     * @param memberId
     * @param status
     * @param type
     * @return
     */
    @RequestMapping(value = "/getOrderByGoodName", method = RequestMethod.POST)
    public Response getOrderByGoodName(@RequestParam Long groupId,@RequestParam String goodsName,@RequestParam Long memberId,@RequestParam Integer status,@RequestParam String type){
        logBefore(logger,"根据商品名称搜索订单信息");
        if(groupId  == null || Tools.isEmpty(goodsName) || Tools.isEmpty(type) || memberId ==null){
            return Response.getError("缺失请求参数");
        }else{
            if(type.equals("0")){
                //服务商品搜索
                try {
                    logBefore(logger,"根据商品名称搜索服务商品订单信息");
                    OrderServiceGood orderServiceGood = new OrderServiceGood();
                    orderServiceGood.setGroupId(groupId);
                    orderServiceGood.setMemberId(memberId);
                    orderServiceGood.setGoodName(goodsName);
                    if(status!=null){
                        orderServiceGood.setOrderStatus(status);
                    }

                   return Response.getSuccess(orderService.getServiceGoodOrderByGoodName(orderServiceGood));
                } catch (Exception e) {
                    e.printStackTrace();
                    logBefore(logger,e.getMessage());
                    return Response.getError(e.getMessage());
                }
            }else if(type.equals("1")){
                //实体商品搜索
                try {
                    logBefore(logger,"根据商品名称搜索实体商品订单信息");
                    MallOrderQueryDTO mallOrderQueryDTO = new MallOrderQueryDTO();
                    mallOrderQueryDTO.setGroupId(groupId);
                    mallOrderQueryDTO.setGoodName(goodsName);
                    mallOrderQueryDTO.setMemberId(memberId);
                    if(status!=null){
                        mallOrderQueryDTO.setStatus(status);
                    }

                   return Response.getSuccess(orderGoodService.getEntityGoodOrderByGoodName(mallOrderQueryDTO));
                } catch (ParseException e) {
                    e.printStackTrace();
                    logBefore(logger,e.getMessage());
                    return Response.getError(e.getMessage());
                }
            }else{
                return Response.getError("参数异常");
            }
        }
    }

}
